//
//  C.swift
//  OnceNectar
//
//  Created by yanghao on 23/05/2018.
//  Copyright © 2018 com.inwhoop. All rights reserved.
//

import Foundation
import MappingAce
import SwiftyJSON

struct CommentModel:Mapping {
    var commentContent :String?
    var jointId :String?
    var likesCount :String?
    var commentatorID :String?
    var statusName :String?
    var id :String?
    var unapprovedReason :String?
    var commentator :String?
    var created :String?
    var commentStatus :String?
    var ifLiked :String?
    var commentType :String?
    var beRepliedUser : AuthorModel?
    var typeName :String?
    var beRepliedUserId :String?
    
    var commentUser :AuthorModel?

    var relatedComments:[CommentModel]
}
extension CommentModel {
    
    mutating func initReplied(dic: [String:Any]) {
        beRepliedUser = AuthorModel(fromDic: dic)
        
    }
    mutating func initAuthor(dic: [String:Any]) {
        commentUser = AuthorModel(fromDic: dic)
        
    }
    mutating func initRelatedComments(arr: [JSON]) {
        
        var xlabers :[CommentModel] = []
        for object in arr {
            
            let xmodel = CommentModel(fromDic: object.dictionary! )
            
            xlabers.append(xmodel)
        }
        relatedComments = xlabers
    }
    
}
